package com.example.base.net

import android.media.session.MediaSession.Token
import com.blankj.utilcode.util.SPUtils
import okhttp3.Interceptor
import okhttp3.Response

class HeaderVideoInterceptor :Interceptor{
    override fun intercept(chain: Interceptor.Chain): Response {
        val string = SPUtils.getInstance().getString("token")
        val request = chain.request()
        if(string!=null){
            request.newBuilder().addHeader("token",string).build()
        }else{
            //正常情况下，不这么写    不想写登录的时候可以临时使用
            request.newBuilder().addHeader("token","eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJ6bGwiLCJleHAiOjE3NDM5OTI3MTl9.UA1Th5XNkkBuW4idW8lYTvVpjAEa0PUvbwgqVUyL1yE").build()
        }
        return chain.proceed(request)
    }

}